package com.zzzy.cont.controller.mycon;


import com.zzzy.common.vo.AjaxResult;
import com.zzzy.cont.service.mycon.MyConArchiveService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

@Tag(name = "我的合同-归档中", description = "con114")
@Validated
@RestController
@RequestMapping("/con/my")
public class MyConArchiveController {

    @Resource
    private MyConArchiveService myConArchiveService;

    @PutMapping("/applyArchive")
    @Operation(summary = "申请归档")
    @Parameter(name = "id", description = "合同ID", required = true)
    @Parameter(name = "userId", description = "用户ID", required = true)
    @PreAuthorize("@pvs.hasPermission('con:my:update')")
    public AjaxResult applyArchive(@NotNull(message = "合同ID不能为空") Long id, @NotNull(message = "用户ID不能为空") Long userId) {
        myConArchiveService.applyArchive(id, userId);
        return AjaxResult.success();
    }

    @PutMapping("/archiveComplete/{id}")
    @Operation(summary = "归档完毕")
    @Parameter(name = "id", description = "合同ID", required = true)
    @PreAuthorize("@pvs.hasPermission('con:my:update')")
    public AjaxResult archiveComplete(@NotNull(message = "合同ID不能为空") @PathVariable("id") Long id) {
        myConArchiveService.archiveComplete(id);
        return AjaxResult.success();
    }

}
